<template>
	<div>
		<el-dialog :title="title" :visible.sync="dialogTableVisible">
			<el-form :model="form" label-width="120px">
				<el-form-item label="数据库类型">
					<el-select v-model="form.baseType" placeholder="请选择">
						<el-option v-for="item in baseTypeOptions" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="IP地址">
					<el-input v-model="form.name" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="端口号">
					<el-input v-model="form.name" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="数据库名称">
					<el-input v-model="form.name" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="TNS网络">
					<el-select v-model="form.tns" placeholder="请选择">
						<el-option v-for="item in tnsOptions" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="数据库连接类型">
					<el-select v-model="form.baseLinkType" placeholder="请选择">
						<el-option v-for="item in baseTypeOptions" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="用户名">
					<el-input v-model="form.name" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="密码">
					<el-input v-model="form.name" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="字符编码">
					<el-select v-model="form.codeType" placeholder="请选择">
						<el-option v-for="item in codeTypeOptions" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogTableVisible = false">取 消</el-button>
				<el-button type="primary" @click="dialogTableVisible = false">确 定</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		props: {
			openType: {
				type: String
			}
		},
		watch: {
			openType(val) {
				if (val == "add") {
					this.title = "添加连接";
				} else if (val == "edit") {
					this.title = "修改连接";
				}
			}
		},
		data() {
			return {
				title: "",
				form: {
					name: '',
					baseType:'',
					tns:'',
					baseLinkType:'',
					codeType:''
				},
				dialogTableVisible: false,
				baseTypeOptions:[
					{
						value: 'sqlserver',
						label: 'sqlserver'
					},
					{
						value: 'oracle',
						label: 'oracle'
					},
				],
				tnsOptions:[
					{
						value: '1',
						label: '是'
					},
					{
						value: '0',
						label: '否'
					},
				],
				codeTypeOptions:[
					{
						value: 'UTF-8',
						label: 'UTF-8'
					},
				]
			}
		},
		methods: {
			show() {
				this.dialogTableVisible = true;
			}
		}
	}
</script>

<style>
</style>
